@using Microsoft.AspNetCore.Localization
@{
    Layout = null;
}
@{
    var requestCulture = Context.Features.Get<IRequestCultureFeature>();
    var culturename = requestCulture.RequestCulture.UICulture.Name;
    if(culturename == "zh")
    {
        culturename = "zh-CN";
    }
}

<link rel="icon" type="image/png" sizes="32x32"
      href="/_content/Elsa.Designer.Components.Web/elsa-workflows-studio/assets/images/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16"
      href="/_content/Elsa.Designer.Components.Web/elsa-workflows-studio/assets/images/favicon-16x16.png">
<link rel="stylesheet" href="/_content/Elsa.Designer.Components.Web/elsa-workflows-studio/assets/fonts/inter/inter.css">
<link rel="stylesheet" href="/_content/Elsa.Designer.Components.Web/elsa-workflows-studio/elsa-workflows-studio.css">
<script src="/_content/Elsa.Designer.Components.Web/monaco-editor/min/vs/loader.js"></script>
<script type="module" src="/_content/Elsa.Designer.Components.Web/elsa-workflows-studio/elsa-workflows-studio.esm.js"></script>
<script type="module"
        src="/_content/Elsa.Designer.Components.Web/elsa-workflows-studio/elsa-workflows-studio.esm.js"></script>


<elsa-studio-root server-url="@($"{Context.Request.Scheme}://{Context.Request.Host}")" tenant=""
                  monaco-lib-path="_content/Elsa.Designer.Components.Web/monaco-editor/min" culture="@culturename">
    <elsa-studio-dashboard culture="@culturename"></elsa-studio-dashboard>
</elsa-studio-root>

<script src="/jquery.min.js"></script>
<script>


    function WtmApprovePlugin(elsaStudio) {
        const {
            eventBus
        } = elsaStudio;

        //eventBus.on('activity-design-displaying', context => {

        //    const activityModel = context.activityModel;

        //    if (activityModel.type !== 'WtmApproveActivity')
        //        return;
        //    const props = activityModel.properties || [];
        //    const syntax = 'Json';
        //    const possibleOutcomes = props.find(x => x.name == 'PossibleOutcomes') || {
        //        expressions: {
        //            'Json': '[]'
        //        },
        //        syntax: syntax
        //    };
        //    var test = props.find(x => x.name == 'PossibleOutcomes');
        //    console.log(test);
        //    const expression = possibleOutcomes.expressions[syntax] || [];
        //    context.outcomes = !!expression['$values'] ? expression['$values'] : Array.isArray(expression) ?
        //        expression : JSON.parse(expression) || [];
        //});
    }

    const elsaStudioRoot = document.querySelector('elsa-studio-root');
    elsaStudioRoot.addEventListener('initializing', e => {
        const elsaStudio = e.detail;
        elsaStudio.pluginManager.registerPlugin(WtmApprovePlugin);
    });

</script>
@if (culturename=="zh-CN")
{
  <script>
        elsaStudioRoot.addEventListener('initialized', e => {
            $("img[alt='Workflow']").remove();
            $("intl-message[label='Workflow Definitions']").html("流程定义");
            $("intl-message[label='Workflow Instances']").html("流程实例");
            $("intl-message[label='Workflow Registry']").remove();
        });
    </script>
}
else
{
    <script>
        elsaStudioRoot.addEventListener('initialized', e => {
            $("img[alt='Workflow']").remove();
            $("intl-message[label='Workflow Registry']").remove();
        });
    </script>

}
